﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditArticle.aspx.cs" EnableEventValidation="false"
    Inherits="Admin_EditArticle" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Article Edit Page</title>
    <link href="../App_Themes/admin.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
    function $(objName) {
        return document.getElementById(objName);
    }
    
    function addToList(objNameTextbox, objNameFileSize, objNameFileName, objNameList) {
        if (($(objNameTextbox) != null) && ($(objNameList) != null)  && ($(objNameFileSize) != null)  && ($(objNameFileName) != null))    {
            var objFile = $(objNameTextbox);
            var objList = $(objNameList);
            if (objFile.value == "")    {
                alert("please enter the file full path including the folder");
                return;
            }
            if ($(objNameFileSize).value == "")    {
                alert("please enter the file size in Kbyte");
                return;
            }
            if ($(objNameFileName).value == "")    {
                alert("please enter the file name");
                return;
            }

            if (objFile.value != "")    {
                var valueToBeAdded, textToBeAdded = "";
                valueToBeAdded = objFile.value;
                if ($(objNameFileName).value != "") {
                    valueToBeAdded += "|" + $(objNameFileName).value;
                    textToBeAdded += $(objNameFileName).value;
                }
                else    {
                    textToBeAdded += objFile.value;
                }
                if ($(objNameFileSize).value != "") {
                    valueToBeAdded += "|" + $(objNameFileSize).value;
                    textToBeAdded += "(" + $(objNameFileSize).value + "K)";
                }
                var option = document.createElement("OPTION");
	            option.value = valueToBeAdded;
	            option.text = textToBeAdded;
	            objList.options.add(option);
	        }
		}
        return true;
    }
    
    function removeFromList(objNameTextbox, objNameList) {
        if ($(objNameList) != null)    {
            var objList = $(objNameList);
            if (objList.selectedIndex != -1) {
                objList.remove(objList.selectedIndex);
            }
        }        
    }
    
    function SelectAll(objNameList)    {
        if ($(objNameList) != null)    {
            var objList = $(objNameList);
            for (var i=0;i<objList.options.length;i++)  {
                objList.options[i].selected = true;
            }
        }   
        return true;     
    }
    
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h3>
                <asp:Label ID="lbTitle" runat="server" Text="Title"></asp:Label>
                <asp:Label ID="lbArticleId" runat="server" Text="" Visible="false"></asp:Label>
                <span id="optionList" runat="server" visible="false"></span><span style="font-size: 9pt;">
                    (请使用简体中文)</span>
            </h3>
            <div id="lbSuccess" runat="server" class="notice-success" visible="false">
            </div>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="notice-failure"
                ForeColor="White" />
            <table width="auto" class="common-form">
                <tr>
                    <td class="label-short">
                        标题:</td>
                    <td>
                        <asp:TextBox ID="txtTitle" runat="server" CssClass="text"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                            Text="*" ErrorMessage="请输入标题" Display="Dynamic"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td class="label-short">
                        内容:</td>
                    <td>
                        <asp:TextBox ID="txtContent" TextMode="MultiLine" Rows="8" runat="server" CssClass="textarea"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtContent"
                            Text="*" ErrorMessage="请输入内容" Display="Dynamic"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td class="label-short">
                        Tags(关键词):</td>
                    <td>
                        <asp:TextBox ID="txtTags" TextMode="SingleLine" runat="server" CssClass="text"></asp:TextBox>
                        (供今后搜索使用)
                    </td>
                </tr>
                <tr>
                    <td class="label-short">
                        附件:</td>
                    <td valign="top">
                        <table widht="100%">
                            <tr>
                                <td>
                                    File Path:&nbsp;
                                    <asp:TextBox ID="txtFiles" runat="server" CssClass="text" Width="213px"></asp:TextBox>
                                    <br />
                                    File Size:&nbsp;&nbsp;
                                    <asp:TextBox ID="txtSize" runat="server" CssClass="text" Width="130px"></asp:TextBox> K
                                    <br />
                                    File Name:
                                    <asp:TextBox ID="txtName" runat="server" CssClass="text" Width="223px"></asp:TextBox>
                                </td>
                                <td valign="bottom">
                                    <input type="button" value="Add" class="button" onclick="return addToList('<%= txtFiles.ClientID %>','<%= txtSize.ClientID %>','<%= txtName.ClientID %>','<%= listAttachment.ClientID %>');" /><br />
                                </td>
                            </tr>
                        </table>
                        <asp:ListBox ID="listAttachment" Width="305px" CssClass="select" SelectionMode="Multiple"
                            runat="server" DataTextField="path" DataValueField="value"></asp:ListBox>
                        &nbsp;
                        <input type="button" value="Remove" class="button" onclick="return removeFromList('<%= txtFiles.ClientID %>','<%= listAttachment.ClientID %>');" /><br />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnSave" runat="server" CssClass="button" Text="Save" OnClick="btnSave_Click" />&nbsp;
                        <asp:Label ID="lbError" runat="server" Text="Label" CssClass="notice-failure" Visible="false"></asp:Label>
                        <input type="button" name="cancel" class="button" value="Cancel" onclick="javascript:parent.parent.GB_hide();"
                            causesvalidation="false" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
